<!-- 新房列表 -->
<template>
	<view class="index-container">
		<view class="search">
			<u-form :model="form">
				<u-search v-model="form.keyword" placeholder="请输入关键字" :show-action="false" @input="search()">
				</u-search>
			</u-form>
		</view>
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="index">
				<view class="con">
					<view class="photo">
						<image :src="item.firstImg" mode=""></image>
					</view>
					<view class="infos">
						<view>{{item.communityName}}</view>
						<view>
							{{item.houseType}} 建面77-166㎡ {{item.countyCode}}
						</view>
						<view>
							28179元/㎡
						</view>
						<view>
							<text v-if="item.buildingNum > 0">
								共{{item.buildingNum}}栋
								在售{{item.saleBuildings}}栋
							</text>
							<text v-else>还未完善楼栋信息</text>
							
						</view>
					</view>
				</view>
				<view class="option-btns">
					<text @click="goSale(item.id)">销售状态和价格</text>
					<text @click="goHome(item.id)">在线建楼</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getRecordsForNewCommunitys
	} from '@/unit/api.js';
	export default {
		data() {
			return {
				form: {
					keyword: "", // 搜索关键字
				},
				list: [],
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			// 搜索
			search() {
				this.getList(this.form.keyword)
			},
			// 获取楼栋列表
			getList(args) {
				let params = {
					communityName: args
				};
				getRecordsForNewCommunitys(params).then(data => {
					this.list = data.data.object.list;
				});
			},
			// 进入销售设置页面
			goSale(id) {
				uni.navigateTo({
					url: `../../../packSale/pages/home/home?id=${id}`
				})
			},
			// 进入在线建楼页面
			goHome(id) {
				uni.navigateTo({
					url: `../home/home?id=${id}`
				})
			},
		},
	}
</script>

<style lang="scss">
	.index-container {
		.search {
			width: 90%;
			margin: auto;
			margin-top: 20rpx;
		}

		.list {
			width: 90%;
			margin: auto;
			margin-top: 20rpx;

			.item {
				padding-bottom: 30rpx;
				border-bottom: 1px solid #E4E4E4;
				margin-bottom: 30rpx;
				&:last-child{
					border-bottom: none;
				}

				.con {
					display: flex;
					align-items: center;

					.photo {
						width: 200rpx;
						height: 160rpx;

						image {
							width: 100%;
							height: 100%;
							border-radius: 10rpx;
						}
					}

					.infos {
						margin-left: 30rpx;

						view {
							&:first-child {
								font-size: 28rpx;
								font-weight: bold;
								color: #333;
							}

							&:nth-child(2) {
								font-size: 24rpx;
								color: #666666;
							}

							&:nth-child(3) {
								font-size: 40rpx;
								color: #E15E32;
								font-weight: bold;
							}

							&:last-child {
								font-size: 24rpx;
								color: #666666;
							}
						}
					}
				}

				.option-btns {
					margin-left: 220rpx;
					margin-top: 20rpx;

					text {
						color: #1A9CEE;
						font-size: 28rpx;
						border: 1px solid #1A9CEE;
						padding: 10rpx;
						border-radius: 50rpx;
						margin-left: 10rpx;
						margin-right: 10rpx;
					}
				}
			}
		}
	}
</style>
